interface IMovie {
	id: string;
	posters: {
		thumbnail: string;
	};
	title: string;
	year: string;
}

import React, { BaseSyntheticEvent } from 'react';
import { Button, FlatList, Image, Text, View } from 'react-native';

export default function tpl(a: <T>(action: string) => ((ev: BaseSyntheticEvent<T>) => void), s: (...class_names: string[]) => {}, d: (d: string) => string | unknown[]) {
	const movies = d('movies') as IMovie[];
	if (movies && JSON.stringify(movies) !== '{}') {
		return (<FlatList
			data={movies} renderItem={renderMovie} style={s('list')} keyExtractor={(item) => item.id} />);
	} else {

		return (<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
			<Text>Home Screen</Text>
			<Button
				title="Go to Details"
				onPress={a('a001')}
			/>
			<Button
				title="render"
				onPress={a('a002')}
			/>
			<Text>{d('txt')}</Text>
			<Text>无数据</Text>
		</View>);
	}

	function renderMovie({ item }: { item: IMovie }) {
		return (
			<View style={s('container')}>
				<Image
					source={{ uri: item.posters.thumbnail }} style={s('thumbnail')}
				/>
				<View style={s('rightContainer')}>
					<Text style={s('title')}>{item.title}</Text>
					<Text style={s('year')}>{item.year}</Text>
				</View>
			</View>
		);
	}
}
